<?php

namespace app\models;

use think\Model;

/**
 * Class ScheduleModel.
 */
class ScheduleModel extends Model
{
    protected $table = 'edu_schedule';

    /**
     * @param $param
     *
     * @throws \think\exception\DbException
     *
     * @return array
     */
    public function getScheduleLists($param)
    {
        $page = isset($param['page']) ? (int) $param['page'] : 1;
        $listRows = isset($param['limit']) ? (int) $param['limit'] : 10;
        $where = [];
        if (isset($param['teacher_name']) && '' !== $param['teacher_name']) {
            $where['teacher_name'] = ['like', $param['teacher_name'].'%'];
        }
        if (isset($param['status']) && '' !== $param['status']) {
            $where['status'] = $param['status'];
        }
        if (isset($param['course_id']) && '' !== $param['course_id']) {
            $where['course_id'] = $param['course_id'];
        }
		if(get_current_type() == 4 || get_current_type() == 5){
			$where['campus_id'] = get_current_campus_id();
		}elseif (get_current_type() == 2 || get_current_type() == 3){
			$where['campus_id'] = ['in',get_current_campus_id()];
		}
		$listData = self::where($where)
			->paginate($listRows, false, ['page' => $page])
			->toArray();
        return $listData;
    }
}
